home *** CD-ROM | disk | FTP | other *** search
- #ifndef SAFEMEM_H
- #define SAFEMEM_H
-
- #ifdef SAFEMEM
-
- #include <exec/types.h>
- #include <exec/memory.h>
-
- /*
- * Compile in safe routines instead of standard library ones
- */
- #define AllocMem(s,t) safe_AllocMem((s),(t), __FILE__, __LINE__)
- #define AllocAbs(s,l) safe_AllocAbs((s),(l), __FILE__, __LINE__)
- #define FreeMem(a,s) safe_FreeMem((a),(s), __FILE__, __LINE__)
- #define ShowMemList() safe_ShowMemList(__FILE__, __LINE__)
- #define FreeMemList() safe_FreeMemList(__FILE__, __LINE__)
-
- #define malloc(s) safe_malloc((s), __FILE__, __LINE__)
- #define free(a) safe_free((a), __FILE__, __LINE__)
- #define realloc(a,s) safe_realloc((a),(s), __FILE__, __LINE__)
- #define calloc(e,s) safe_calloc((e),(s), __FILE__, __LINE__)
-
- void *safe_AllocMem(ULONG Size, ULONG MemType, char *File, ULONG Line),
- *safe_AllocAbs(ULONG Size, void *Location, char *File, ULONG Line),
- safe_FreeMem(void *Address, ULONG Size, char *File, ULONG Line);
-
- ULONG safe_ShowMemList(char *File, ULONG Line),
- safe_FreeMemList(char *File, ULONG Line);
-
- void *safe_malloc(ULONG Size, char *File, ULONG Line);
- void safe_free(void *Address, char *File, ULONG Line);
- void *safe_realloc(void *Address, ULONG NewSize, char *File, ULONG Line);
- void *safe_calloc(ULONG Elements, ULONG ElementSize, char *File, ULONG Line);
-
- /*
- * When gbl_SafeMem == 0, the SafeMem routines merely call the real versions,
- * without any of the SafeMem checking. This provides an easy way to disable
- * SafeMem without recompiling your entire program.
- */
- extern ULONG far gbl_SafeMem;
-
- /*
- * gbl_SafeMemOutput is the function that is called to print the messages.
- * The default is a printf() to stdout.
- */
- extern void (*gbl_SafeMemOutput)();
-
- #else
- /*
- * Define away our routines into nothing
- */
- #define ShowMemList()
- #define FreeMemList()
-
- #endif
- #endif
-